#include "CommonNotify.h"
#include "NotifyDefine.h"
#include "model/proxy/CommonProxy.h"
#include "model/proxy/UserProxy.h"
CommonNotify::CommonNotify()
{
	
}

CommonNotify::~CommonNotify()
{

}

void CommonNotify::registerNotify()
{
	CCArray* nameList = CCArray::create(ccs(kVCLevelUp),NULL);
	RegisterObservers(this, nameList, callfuncO_selector(CommonNotify::_onNotification)); 
}

void CommonNotify::_onNotification( CCObject* object )
{
	CCLog("PacketScene::_onNotification");
	NotificationObserver* observer = (NotificationObserver*)object;
	std::string name(observer->getName());
	if (name == kVCLevelUp)
	{
		int& lastLevel = CommonProxy::getSingletonPtr()->lastLevel;
		int curLevel = UserProxy::getSingletonPtr()->userVO.level;
		if(curLevel > lastLevel)
		{
			lastLevel = curLevel;
			Framework::getSingletonPtr()->popup("LevelUpDialog", NULL);
		}
	}
}